package com.cyz.user.userService.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyz.common.bean.Button;
import com.cyz.common.enums.MyEnums;
import com.cyz.common.mapper.ButtonMapper;
import com.cyz.common.utils.BeanCopyUtil;
import com.cyz.common.utils.R;
import com.cyz.user.userService.ButtonService;
import com.cyz.user.vo.ButtonVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 34928
* @description 针对表【button】的数据库操作Service实现
* @createDate 2023-02-20 10:52:22
*/
@Service
public class ButtonServiceImpl extends ServiceImpl<ButtonMapper, Button>
    implements ButtonService {

    @Override
    public R queryFreeButtons() {
        //查询数据
        List<Button> list = list();
        //vo转化
        List<ButtonVo> buttonVos = BeanCopyUtil.copyBeanList(list, ButtonVo.class);
        //错误判断
        if(buttonVos.isEmpty()){
            return R.error(MyEnums.QUERY_FAIL);
        }
        return R.success(buttonVos);
    }
}




